//
//  QZTabBar.m
//  QZ浪里个浪
//
//  Created by 秦－政 on 2016/10/24.
//  Copyright © 2016年 pete. All rights reserved.
//

#import "QZTabBar.h"
#import "UIButton+QZAddition.h"

@interface QZTabBar ()
// 按键
@property (nonatomic,strong) UIButton *composeButton;
@property (nonatomic,strong) UIButton *composeB;
@end
@implementation QZTabBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}
#pragma mark - 搭建界面
- (void)setupUI
{
    [self addSubview:self.composeButton];

}
// 监听事件
- (void)buttonClick
{
    NSLog(@"撰写按键被点了");
    
    
}
// 设置按键的frame
- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w = SLSCREENW * .2;
    CGFloat index = 0;
    CGFloat h = self.bounds.size.height;
    // 遍历tabBar的子控件 布局系统的按键位置
    for (UIView *btn in self.subviews) {
        if ([btn isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            btn.frame = CGRectMake(w * index, 0, w, h);
            index += 1;
            if (index == 2) {
                index += 1;
            }
        }
        
    }
    _composeButton.center = CGPointMake(SLSCREENW * .5,self.bounds.size.height *.5);
}
// 懒加载撰写按键
- (UIButton *)composeButton
{
    if (!_composeButton) {
        _composeButton = [UIButton QZ_setImgName:@"tabbar_compose_icon_add" backgroundImgName:@"tabbar_compose_button" target:self action:@selector(buttonClick)];
    }
    return _composeButton;
}
@end
